import requests


headers = {
    "authority": "weread.qq.com",
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "referer": "https://weread.qq.com/",
    "sec-ch-ua": "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Linux\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
}

url = "https://weread.qq.com/web/search/search_suggest"
params = {
    "keyword": "1984", # 搜索的关键词
    "count": "40"
}
response = requests.get(url, headers=headers, params=params)

# print(response.json()['records'])
# print(response)

book_list=response.json()['records']
for i in book_list:
    if not i['type']:
        print(i['word'],'-----------------',i['bookId'])